package com.java01.apache.commons.cli;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;

public class DefineOption1 {

	public static void main(String[] args){
		Options options = new Options();

		options.addOption("h", false, "Display usage");
		
		CommandLineParser parser = new PosixParser();
		CommandLine cmd = null;
		try {
			cmd = parser.parse( options, args);
		} catch (ParseException e) {
			System.err.println(e.getMessage());
			System.exit(1);
		}
		
		if(cmd.hasOption("-h") || args.length==0){
			HelpFormatter formatter = new HelpFormatter();
			formatter.printHelp( "DefineOption1", options );
		}
	}
}
